<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>


    function jumpSteps(n) {
        debugger;
        if (n === 0) return 1; // 0级台阶  
        if (n === 1) return 1; // 1级台阶  

        let prev2 = 1; // f(0)  
        let prev1 = 1; // f(1)  
        let current;

        for (let i = 2; i <= n; i++) {
            current = prev1 + prev2; // f(n) = f(n-1) + f(n-2)  
            prev2 = prev1; // 更新 f(n-2)  
            prev1 = current; // 更新 f(n-1)  
        }

        return current;
    }

    // 测试  
    console.log(jumpSteps(5)); // 输出跳上5级台阶的不同跳法总数

    </script>
</body>
</html>